<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript">
			window.onload = function() {
				var my_btn = document.getElementById("btn");

				my_btn.onclick = function() {
					//通过name属性值来获取元素
					var my_sex = document.getElementsByName("sex");
					console.log(my_sex);
				}
			}
		</script>
	</head>

	<body>
		<input type="button" id="btn" value="提交" />
		<input type="radio" name="sex" value="男" />男
		<input type="radio" name="sex" value="女" />女
	</body>

</html>